//
//  CSDateUtils.swift
//  Cycling
//
//  Created by CSS on 4/21/23.
//

import Foundation

// MARK: 时间工具类
extension NSDate {
    
    @objc func moveToBeginOfTheDate() -> NSDate {
        
        let dateComponents = Calendar.current.dateComponents([.year, .month, .day], from: self as Date)
        
        return Calendar.current.date(from: dateComponents)! as NSDate
    }
    
    @objc func dateMove(byDay day: Int) -> NSDate {
        
        var addComponents = DateComponents()
        addComponents.day = day
        
        return Calendar.current.date(byAdding: addComponents, to: self as Date)! as NSDate
        
    }
    
}
